package com.system.web.servlet;

import com.alibaba.fastjson.JSON;
import com.system.dao.DictionaryDao;
import com.system.dao.RoleDao;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CommonTreeServlet extends BaseServlet
{
  private static final long serialVersionUID = 2390039192028481753L;

  public void getDictionaryTree(HttpServletRequest request, HttpServletResponse response)
  {
    DictionaryDao dao = new DictionaryDao();
    List list = dao.getDictionaryList();
    try {
      writeJsonReuslt(response, JSON.toJSONString(list != null ? list : ""));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  public void getPrivilegeTree(HttpServletRequest request, HttpServletResponse response)
  {
    RoleDao dao = new RoleDao();
    String roleId = request.getParameter("roleId");
    List list = dao.getPrivilegeList(roleId);
    try {
      writeJsonReuslt(response, JSON.toJSONString(list != null ? list : ""));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}